package top.xchch.tool.mockito.juejin;

import org.junit.Test;

import java.util.List;

import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;

/**
 * doReturn()|doThrow()| doAnswer()|doNothing()|doCallRealMethod()等用法
 *
 * @author sai.zhang
 * @date 2021-08-31 15:01
 */
public class DoXxxTest11 {
    @Test
    public void testDoXXX() throws Exception {
        List mockedList = mock(List.class);
        doThrow(new RuntimeException()).when(mockedList).clear();
        //以下会抛异常
        mockedList.clear();
    }


}
